﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Abp.Dependency;
using Abp.Domain.Repositories;
using Abp.Events.Bus.Handlers;
using Abp.Runtime.Caching;
using ARchGL.Platform.Application;
using ARchGL.Platform.Core;
using ARchGL.Platform.EventHandlers.Events;

namespace ARchGL.Platform.EventHandlers
{
    /// <summary>
    /// 公告分发 Handler
    /// </summary>
    public class SendNoticeEventHandler : IAsyncEventHandler<SendNoticeEvent>, ITransientDependency
    {
        private readonly IRepository<NoticesUsers, Guid> noticesUsersRepository;

        public SendNoticeEventHandler(IRepository<NoticesUsers, Guid> _noticesUsersRepository)
        {
            noticesUsersRepository = _noticesUsersRepository;
        }

        public async Task HandleEventAsync(SendNoticeEvent e)
        {
            //Thread.Sleep(10000);
            await noticesUsersRepository.InsertAsync(e.NoticeId, e.CurrentUserId, e.UserIdList);
        }
    }
}
